package org.pb.basic.utils;

/**
 * @author 10844
 * 返回JSON对象的响应对象
 * @param <T>
 */
public class AjaxResult<T> {
	
	private Boolean success;
	
	private String msg;
	
	private T data;
	
	public AjaxResult() {}

	public AjaxResult(Boolean success, String msg, T data) {
		super();
		this.success = success;
		this.msg = msg;
		this.data = data;
	}

	public AjaxResult(Boolean success, T data) {
		super();
		this.success = success;
		this.data = data;
	}

	public AjaxResult(T data) {
		super();
		this.data = data;
	}
	
	
	public AjaxResult(Boolean success, String msg) {
		super();
		this.success = success;
		this.msg = msg;
	}

	public static <T> AjaxResult<T> successWithMessage(String msg) {
		return new AjaxResult<T>(true, msg);
	}

	public static <T> AjaxResult<T> failedWithMessage(String msg) {
		return new AjaxResult<T>(false, msg);
	}
	
	public static <T> AjaxResult<T> successWithData(T data) {
		return new AjaxResult<T>(true, "success", data);
	}

	public static <T> AjaxResult<T> failedWithData(T data) {
		return new AjaxResult<T>(false, data);
	}
	
	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
